#!/usr/bin/env bash

# 【服务端执行】创建keystore，创建一个alias
keytool -genkey -alias jichengceshi -keyalg RSA -keysize 1024 -keypass jicheng123 -validity 364 -keystore D:/key/server/jicheng.keystore -storepass ideal123 -dname "CN=Think, OU=Think, O=Think, L=SH, ST=SH, C=CN"
# 【服务端执行】从指定的keystore中将一个制定的alias的certificate导出成本地文件
keytool -export -alias jichengceshi -keystore D:/key/server/jicheng.keystore -file D:/key/server/jichengceshi.crt -storepass ideal123

# 【客户端执行】将server端的certificate文件导入client服务器端的keystore
keytool -genkey -alias jichengclient -keyalg RSA -keysize 1024 -keypass jichengclient123 -validity 364 -keystore D:/key/client/jichengclient.keystore -storepass ideal123 -dname "CN=Think, OU=Think, O=Think, L=SH, ST=SH, C=CN"
keytool -import -v -file D:/key/server/jichengceshi.crt -keystore D:/key/client/jichengclient.keystore -storepass ideal123 -alias jichengceshi